package cn.iocoder.yudao.module.blog.dal.mysql.spacecomment;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.blog.controller.app.space.commentvo.AppBlogSpaceCommentPageReqVO;
import cn.iocoder.yudao.module.blog.dal.dataobject.spacecomment.BlogSpaceCommentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.blog.controller.admin.spacecomment.vo.*;

/**
 * 动态评论 Mapper
 *
 * @author 曹建伟
 */
@Mapper
public interface BlogSpaceCommentMapper extends BaseMapperX<BlogSpaceCommentDO> {

    default PageResult<BlogSpaceCommentDO> selectPage(BlogSpaceCommentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BlogSpaceCommentDO>()
                .eqIfPresent(BlogSpaceCommentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogSpaceCommentDO::getRespondCommentId, reqVO.getRespondCommentId())
                .betweenIfPresent(BlogSpaceCommentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlogSpaceCommentDO::getId));
    }

    default List<BlogSpaceCommentDO> selectList(BlogSpaceCommentExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BlogSpaceCommentDO>()
                .eqIfPresent(BlogSpaceCommentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogSpaceCommentDO::getRespondCommentId, reqVO.getRespondCommentId())
                .betweenIfPresent(BlogSpaceCommentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BlogSpaceCommentDO::getId));
    }

    default PageResult<BlogSpaceCommentDO> appSelectPage(AppBlogSpaceCommentPageReqVO reqVO){
        return selectPage(reqVO, new LambdaQueryWrapperX<BlogSpaceCommentDO>()
                .eqIfPresent(BlogSpaceCommentDO::getMemberId, reqVO.getMemberId())
                .eqIfPresent(BlogSpaceCommentDO::getSpaceId, reqVO.getSpaceId())
                .eqIfPresent(BlogSpaceCommentDO::getMainCommentId, reqVO.getMainCommentId())
                .orderByDesc(BlogSpaceCommentDO::getId));
    }

}
